﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using Dashboard.Expense.Business;

namespace Dashboard.Expense
{
    public partial class FormPrintDialog : Form
    {
        public int ID { get; set; }
        public int FormNo { get; set; }
        
        public FormPrintDialog()
        {
            InitializeComponent();
        }

        private void FormPrintDialog_Load(object sender, EventArgs e)
        {
            try
            {
                this.reportViewerMain.LocalReport.DataSources.Clear();

                DataTable header = new Exp_ExpenseForm().QueryFormInfoForPrint(this.ID);
                DataTable detail = new Exp_ExpenseForm().QueryFormLinesForPrint(this.FormNo);

                this.reportViewerMain.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSetFormHead", header));
                this.reportViewerMain.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("DataSetFormLine", detail));

                // SetParameters
                List<ReportParameter> paras = new List<ReportParameter>();
                paras.Add(new ReportParameter("BaseCurrency", new BusinessBase().GetBaseCurrency()));
                this.reportViewerMain.LocalReport.SetParameters(paras);

                this.reportViewerMain.RefreshReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);                
            }
        }
    }
}
